package work1;

import Uti.ScannerUti;
import work1.PersonnelManagementSystem;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;

public class Works1 {
    public static void work() {
        while (true) {
            System.out.println("请选择题目序号：1——题目1： 2——题目2： 0——退出");
            int kk = ScannerUti.getInt();

            if(kk==1)doWork1();
            else if (kk==2)doWork2();
            else if (kk == 0) break;
        }
    }


    private static void doWork1() {
        //Monday、Tuesday、Wednesday、Thursday、Friday、Saturday、Sunday
        LocalDateTime today = LocalDateTime.now();
        //当前日期
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String formattedDateTime = today.format(formatter);
        //月初
        LocalDate firstDarOfMonth = LocalDate.of(today.getYear(),today.getMonth(),1);
        String firstDay = firstDarOfMonth.getDayOfWeek().toString().toLowerCase();
        ArrayList<String> list=new ArrayList<>();
        Collections.addAll(list,"monday","tuesday","wednesday","thursday","friday","saturday","sunday");
        System.out.println("------------"+formattedDateTime+"------------");
        System.out.println("一\t二\t三\t四\t五\t六\t日");
        int star = list.indexOf(firstDay);
        for(int i=0;i<star;i++) System.out.print(" \t");
        for (int i=star+1;i<=star+today.toLocalDate().lengthOfMonth();i++){
            System.out.print(i-star+"\t");
            if(i%7==0) System.out.println();
        }
        System.out.println();

    }

    private static void doWork2() {
        PersonnelManagementSystem.menu();
    }
}
